package com.IoLiu;

import java.io.*;

public class Zifuliu {
    public static void main(String[] args) throws IOException {
        OutputStreamWriter osw=new OutputStreamWriter(new
                FileOutputStream("D:\\下载\\file\\file1\\字符流编码.txt",true),"GBK");
        char[] ch=new char[]{'a', 'b', 'c', 'd', 'e'};
        osw.write("\r\n");
        osw.write(ch,1,4);
        osw.close();
//        InputStreamReader isr=new InputStreamReader(new FileInputStream("D:\\下载\\file\\file1\\字符流编码.txt"));
//        int len;
//        while((len=isr.read())!=-1){
//            System.out.println((char)len);
//        }
        InputStreamReader isr=new InputStreamReader(new FileInputStream("D:\\下载\\file\\file1\\字符流编码.txt"),"GBK");
        char[] cs=new char[1024];
        int index;
        while((index=isr.read(cs))!=-1){
            System.out.println(new String(cs,0,index));
        }
    }
}
